//----------------------------------------------------------------------------
//  ,-.
// /_\___ ,   Ninja Framework
// '  ___\    (C) Riccardo Capra - http://riccar.do
//  //   \\
//----------------------------------------------------------------------------
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------

#ifndef NJ_PLATFORM_SYNC_OBJECT_LINUX_INLINE_H
#	define NJ_PLATFORM_SYNC_OBJECT_LINUX_INLINE_H

	//----------------------------------------------------------------------------
	inline void NjPlatformSyncObject::Initialize(SyncObject & kSyncObject)
	{
		pthread_mutex_init(&kSyncObject, NJ_NULL);
	}
	//----------------------------------------------------------------------------
	inline void NjPlatformSyncObject::Lock(SyncObject & kSyncObject)
	{
		pthread_mutex_lock(&kSyncObject);
	}
	//----------------------------------------------------------------------------
	inline NjBool NjPlatformSyncObject::TryLock(SyncObject & kSyncObject, TimeMs uTimeMs)
	{
		NJ_UNUSED_VAR(uTimeMs);
		return pthread_mutex_trylock(&kSyncObject)==0;
	}
	//----------------------------------------------------------------------------
	inline void NjPlatformSyncObject::Unlock(SyncObject & kSyncObject)
	{
		pthread_mutex_unlock(&kSyncObject);
	}
	//----------------------------------------------------------------------------
	inline void NjPlatformSyncObject::Destroy(SyncObject & kSyncObject)
	{
		pthread_mutex_destroy(&kSyncObject);
	}
	//----------------------------------------------------------------------------
	inline NjCharA const * NjPlatformSyncObject::GetName()
	{
		return "pthread_mutex_t";
	}
	//----------------------------------------------------------------------------

#endif // NJ_PLATFORM_SYNC_OBJECT_LINUX_INLINE_H
